shairport: Update config and init scripts, fix build, remove libao dependency, add...
authorthess <[email protected]>
Wed, 16 Jul 2014 17:51:18 +0000 (13:51 -0400)
committerTed Hess <[email protected]>
Wed, 16 Jul 2014 19:33:11 +0000 (15:33 -0400)
Signed-off-by: Ted Hess <[email protected]>
multimedia/shairport/Makefile
multimedia/shairport/files/shairport.config
multimedia/shairport/files/shairport.init
multimedia/shairport/patches/001-disable_pulseaudio.patch

index c66a9daf7f4ae85b7ef064daf56e8bf05595ecd3..152ddc3a01c6c968311ae38159dbc29c644fd97f 100644 (file)
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2013 OpenWrt.org
+# Copyright (C) 2013-2014 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -9,21 +9,21 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=shairport
 PKG_VERSION:=2014-05-08
-PKG_RELEASE:=$(PKG_SOURCE_VERSION)
+PKG_RELEASE:=2
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL:=git://github.com/abrasive/shairport.git
 PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
 PKG_SOURCE_VERSION:=078b21043cdcef6ffad7452db27f036770b23b0c
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
+PKG_MAINTAINER:=Ted Hess <[email protected]>
 
 include $(INCLUDE_DIR)/package.mk
 
 define Package/shairport
   SECTION:=multimedia
   CATEGORY:=Multimedia
-  DEPENDS:=+libpthread +avahi-utils +libopenssl +libao +libavahi-client \
-       +alsa-utils
+  DEPENDS:=+libpthread +avahi-utils +libopenssl +libavahi-client +alsa-utils
   TITLE:=ShairPort AirPort Express emulator
 endef
 
@@ -39,15 +39,15 @@ endef
 
 TARGET_CFLAGS += $(FPIC)
 
-LIBS:=-lao -lm -lcrypto -lpthread -lavahi-common -lavahi-client -lasound
+LIBS:=-lm -lcrypto -lpthread -lavahi-common -lavahi-client -lasound
 
 MAKE_FLAGS += \
        CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
        LDFLAGS="$(TARGET_LDFLAGS) $(LIBS)"
 
 define Package/shairport/install
-       $(INSTALL_DIR) $(1)/usr/sbin
-       $(INSTALL_BIN) $(PKG_BUILD_DIR)/shairport $(1)/usr/sbin/
+       $(INSTALL_DIR) $(1)/usr/bin
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/shairport $(1)/usr/bin/
        $(INSTALL_DIR) $(1)/etc/init.d/
        $(INSTALL_BIN) files/shairport.init $(1)/etc/init.d/shairport
        $(INSTALL_DIR) $(1)/etc/config
index 74e67cb9c419e8d2a22306cc0b96a7bc0ab3fee4..851c927e49a2489db8e20be4967231c6678138d8 100644 (file)
@@ -1,11 +1,18 @@
-config shairport
-       option name 'AirPort'
+config shairport main
+       option bname 'AirPort'
        option password ''
        option port '5002'
        option buffer '256'
-       option log '/var/log/shairport'
+       option log ''
        option cmd_start ''
        option cmd_stop ''
-       option cmd_wait '0'
-       option audio_output ''
-       option mdns ''
+       option cmd_wait ''
+       option audio_output 'alsa'
+       option mdns 'avahi'
+
+       # options for alsa output
+       option output_dev ''
+       option mixer_dev ''
+       option mixer_type ''
+       option mixer_control ''
+       option mixer_index ''
index 2136bc26c4d27b5b911b2b9257153492a3a05d09..99132be121a9d0829bd889b24bff2cf3bf6fc501 100644 (file)
@@ -1,53 +1,91 @@
 #!/bin/sh /etc/rc.common
-# Copyright (C) 2013-2014 OpenWrt.org
 
-START=50
-USE_PROCD=1
+NAME=shairport
+START=94
 
-config_shairport() {
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+
+AP_PIDDIR=/var/run
+AP_BIN=/usr/bin/shairport
+
+append_arg() {
+        local cfg="$1"
+        local var="$2"
+        local opt="$3"
+        local def="$4"
+        local val
+
+        config_get val "$cfg" "$var"
+        [ -n "$val" -o -n "$def" ] && append AP_ARGS "$opt ${val:-$def}"
+}
+
+append_bool() {
+        local cfg="$1"
+        local var="$2"
+        local opt="$3"
+        local def="$4"
+        local val
+
+        config_get_bool val "$cfg" "$var" "$def"
+        [ "$val" = 1 ] && append AP_ARGS "$opt"
+}
+
+start_instance() {
+       AP_ARGS=""
+       local cfg="$1"
+       local ao dev
+
+       append_arg "$cfg" bname "-a" "AirPort"
+       append_arg "$cfg" log "-l"
+       append_arg "$cfg" initbuf "-b" "256"
+       append_arg "$cfg" port "-p" "5002"
+       append_arg "$cfg" password "-k"
+       append_arg "$cfg" mdns "-m"
+
+       append_arg "$cfg" cmd_start "-B"
+       append_arg "$cfg" cmd_stop "-E"
+       append_bool "$cfg" cmd_wait "-w"
+
+       append_arg "$cfg" audio_output "-o"
+
+       config_get ao "$cfg" audio_output ""
+       if [ "$ao" = "alsa" ]; then
+               config_get dev "$cfg" output_device ""
+               if [ -n "$dev" ]; then
+                       append AP_ARGS "--"
+                       append_arg "$cfg" output_device "-d"
+                       append_arg "$cfg" mixer_device "-m"
+                       append_arg "$cfg" mixer_type "-t"
+                       append_arg "$cfg" mixer-control "-c"
+                       append_arg "$cfg" mixer-index "-i"
+               fi
+       fi
+
+       SERVICE_PID_FILE=${AP_PIDDIR}/${NAME}_${cfg}.pid
+       service_start $AP_BIN $AP_ARGS
+
+       # Check if daemon is running, if not then
+       # re-execute in foreground to display error.
+       sleep 1 && service_check $AP_BIN || \
+               $AP_BIN $AP_ARGS
+}
+
+stop_instance()
+{
        local cfg="$1"
 
-       local cfg_name
-       local cfg_password
-       local cfg_port
-       local cfg_buffer
-       local cfg_log
-       local cfg_cmd_start
-       local cfg_cmd_stop
-       local cfg_cmd_wait
-       local cfg_audio_output
-       local cfg_mdns
-
-       config_get cfg_name $cfg 'name' 'AirPort'
-       config_get cfg_password $cfg 'password' ''
-       config_get cfg_port $cfg 'port' '5002'
-       config_get cfg_buffer $cfg 'buffer' '256'
-       config_get cfg_log $cfg 'log' '/var/log/shairport'
-       config_get cfg_cmd_start $cfg 'cmd_start' ''
-       config_get cfg_cmd_stop $cfg 'cmd_stop' ''
-       config_get_bool cfg_cmd_wait $cfg 'cmd_wait' '0'
-       config_get cfg_audio_output $cfg 'audio_output' ''
-       config_get cfg_mdns $cfg 'mdns' ''
-
-       procd_open_instance
-
-       procd_set_param command /usr/sbin/shairport
-       procd_append_param command -a "$cfg_name"
-       [ ! -z "$cfg_password" ] && procd_append_param command -k "$cfg_password"
-       procd_append_param command -p $cfg_port
-       procd_append_param command -b $cfg_buffer
-       procd_append_param command -l $cfg_log
-       [ ! -z "$cfg_cmd_start" ] && procd_append_param command -B "$cfg_cmd_start"
-       [ ! -z "$cfg_cmd_stop" ] && procd_append_param command -E "$cfg_cmd_stop"
-       [ "$cfg_cmd_wait" -eq 1 ] && procd_append_param command -w
-       [ ! -z "$cfg_audio_output" ] && procd_append_param command -o "$cfg_audio_output"
-       [ ! -z "$cfg_mdns" ] && procd_append_param command -m "$cfg_mdns"
-
-       procd_set_param respawn
-       procd_close_instance
+       SERVICE_PID_FILE=${AP_PIDDIR}/${NAME}_${cfg}.pid
+       SERVICE_SIG_STOP="INT"
+       service_stop $AP_BIN
+}
+
+start() {
+       config_load shairport
+       config_foreach start_instance shairport
 }
 
-start_service() {
+stop() {
        config_load shairport
-       config_foreach config_shairport shairport
+       config_foreach stop_instance shairport
 }
index 12ec089d13b4bda04edf4b42693288bc04a7f795..7f0407e2ba7a8f1ce3a8aa33a18b1b1caf9edb8b 100644 (file)
@@ -3,8 +3,9 @@
 @@ -59,7 +59,7 @@ do_pkg_config()
  
  do_pkg_config OpenSSL       openssl
- do_pkg_config libao         ao              CONFIG_AO
+-do_pkg_config libao         ao              CONFIG_AO
 -do_pkg_config PulseAudio    libpulse-simple CONFIG_PULSE
++#do_pkg_config libao         ao              CONFIG_AO
 +#do_pkg_config PulseAudio    libpulse-simple CONFIG_PULSE
  do_pkg_config ALSA          alsa            CONFIG_ALSA
  do_pkg_config Avahi\ client avahi-client    CONFIG_AVAHI